package com.kefu.smartCall.vo;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.common.vo.AbstractSearchVo;
import com.kefu.smartCall.model.ScTask;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Objects;

@Data
@ApiModel
public class ScTaskSearchVo extends AbstractSearchVo {
    @ApiModelProperty(value = "任务名")
    private String taskName;

    @ApiModelProperty("机构id")
    private String tenantId;

    @ApiModelProperty(value = "大模型筛选进度 -1=不通过， 0=未筛选，1=通过")
    private Integer searchState;

    @ApiModelProperty(value = "外呼状态 0 未开始，1进行中，2暂停，3 结束", name = "taskStatus")
    private Integer taskStatus;

    @Override
    public LambdaQueryWrapper lambdaQuery() {
        LambdaQueryWrapper<ScTask> wrapper = Wrappers.lambdaQuery(ScTask.class);
        if (StrUtil.isNotBlank(taskName)) {
            wrapper.like(ScTask::getTaskName, taskName);
        }
        if (StrUtil.isNotBlank(tenantId)) {
            wrapper.eq(ScTask::getTenantId, tenantId);
        }
        if (Objects.nonNull(searchState)) {
            wrapper.eq(ScTask::getSearchState, searchState);
        }
        if (Objects.nonNull(taskStatus)) {
            wrapper.eq(ScTask::getTaskStatus, taskStatus);
        }
        wrapper.orderByDesc(ScTask::getUpdateTime);
        return wrapper;
    }
}
